package team.tunan.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import team.tunan.common.Result;
import team.tunan.dto.SupplierPageDto;
import team.tunan.entity.Supplier;
import team.tunan.service.ISupplierService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sqx
 * @since 2023-12-24
 */
@RestController
@RequestMapping("/supplier")
public class SupplierController {
    @Autowired
    private ISupplierService iSupplierService;

    @PostMapping("/insertSupplier")
    public Result insertSupplier(@RequestBody Supplier supplier){
        return Result.success(iSupplierService.insertSupplier(supplier));
    }

    @PostMapping("/updateSupplier")
    public Result updateSupplier(@RequestBody Supplier supplier){
        return Result.success(iSupplierService.updateSupplier(supplier));
    }

    @GetMapping("/deleteSupplier/{id}")
    public Result deleteSupplier(@PathVariable String id){
        return Result.success(iSupplierService.deleteSupplier(id));
    }


    @PostMapping("/selectPage")
    public Result<Page<Supplier>> selectPage(@RequestBody SupplierPageDto supplierPageDto){
        return Result.success(iSupplierService.selectPage(supplierPageDto));
    }

    @GetMapping("/list")
    public Result list(){
        return Result.success(iSupplierService.list());
    }
}

